using System;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Media;
using FluentAvalonia.UI.Windowing;

namespace DevManager.Views;

public partial class MainWindow : AppWindow
{
    public MainWindow()
    {
        InitializeComponent();
        SplashScreen = new MainAppSplashScreen();
        TitleBar.ExtendsContentIntoTitleBar = true;
        TitleBar.TitleBarHitTestType = TitleBarHitTestType.Complex;
    }
}

internal class MainAppSplashScreen : IApplicationSplashScreen
{
    public string AppName => "DevManager";
    public IImage? AppIcon { get; set; } 
    public object SplashScreenContent => new StartView();
    public int MinimumShowTime => 2000;

    private Action? InitApp { get; set; }

    public Task RunTasks(CancellationToken cancellationToken)
    {
        return InitApp == null ? Task.CompletedTask : Task.Run(InitApp, cancellationToken);
    }
}